import paramiko

# 定义一个命令执行并输出结果的函数
def execute_remote_command(host, port, command, username, password)
    try:
        # 创建客户端对象
        client = paramiko.SSHClient()
        client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        # 连接与执行
        client.connect(host, port, username, password)
        _, stdout, stderr = client.exec_command(command)

        # 输出结果
        output  = stdout.read().decode()
        error = stderr.read().decode()

        # 断开连接
        client.close()

        return output, error
    
    except Exception as e:
        return None, str(e)